<template>
  <el-dialog
    title="题目审核"
    :visible.sync="isShowCheckDialog"
    width="20%"
    :before-close="handleClose"
  >
    <el-form ref="form" :model="form" label-width="80px">
      <el-row>
        <el-col :span="24"
          ><div class="grid-content bg-purple-dark">
            <el-form-item label-width="0">
              <el-radio-group v-model="form.chkState">
                <el-radio :label="1">通过</el-radio>
                <el-radio :label="2">拒绝</el-radio>
              </el-radio-group>
            </el-form-item></div
        ></el-col>
      </el-row>
      <el-row>
        <el-col :span="24"
          ><div class="grid-content bg-purple-dark">
            <el-form-item label-width="0">
              <el-input
                type="textarea"
                v-model="form.chkRemarks"
                placeholder="请输入审核意见"
              ></el-input>
            </el-form-item></div
        ></el-col>
      </el-row>
      <el-row>
        <el-col :span="24"
          ><div class="grid-content bg-purple-dark">
              <el-button class="button" type="primary" @click="onSubmit"
              >确 定</el-button
            >
            <el-button class="button" @click="$emit('close')">取 消</el-button>
          </div></el-col
        >
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'checkDialog',
  props: {
    isShowCheckDialog: {
      type: Boolean,
      default: false
    },
    id: {
      type: [String, Number],
      require: true
    }
  },
  data () {
    return {
      form: {
        chkState: 1,
        chkRemarks: ''
      }
    }
  },
  methods: {
    async onSubmit () {
      if (!this.form.chkRemarks) return this.$message.warning('请输入审核意见')
      const res = await choiceCheck({ id: this.id, ...this.form })
      if (!res.data.success) return this.$message('操作失败')
      this.$message.success('操作成功')
      this.$emit('close')
      this.$emit('submit')
    },

    // 点击关闭按钮的方法
    handleClose () {
      this.$emit('close')
    }
  }
}
</script>

<style scoped>
.button {
    float: right;
    margin-left: 10px;
}
</style>
